package com.example.room.course

import androidx.room.*

@Dao
interface CourseDao {
    // 查询
    @Query("SELECT * FROM COURSE")
    fun queryAllDesk(): MutableList<Course>

    //根据姓名参数查询
    @Query("SELECT * FROM COURSE WHERE id = :id")
    fun queryFindDesk(id: String): Course?

    @Query("SELECT * FROM COURSE ORDER BY id DESC LIMIT 1")
    fun queryDeskMax(): Course?

    @Query("SELECT * FROM COURSE ORDER BY id DESC LIMIT 1")
    fun queryUserMax(): Course?

    // 添加单条数据
    @Insert
    fun addDesk(vararg desk: Course)

    // 添加批量数据
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun addBatchDesk(list: MutableList<Course>)

    // 更新某一个数据
    @Update
    fun updateDesk(vararg desk: Course)

    //删除某一个数据
    @Delete
    fun deleteSingle(vararg desk: Course)

    //删除表里所有数据
    @Query("DELETE FROM COURSE")
    fun deleteAllDesk()
}